import Vue from 'vue'
import Router from 'vue-router'
import { role } from '@/lib/config'
import Main from '@/view/Main'
import Main2 from '@/view/Main2'
import Index from '@/view/Index' //首页


import Course from '@/view/Course' // 我的课程
import CourseIndex from '@/view/CourseIndex' // 我的课程 路由页面
import CourseIndex2 from '@/view/course/Index' // 我的课程子页面 首页
import CourseStatistics from '@/view/course/Statistics' // 我的课程子页面 统计
import CourseMaterial from '@/view/course/Material' // 我的课程子页面 资料
import TaskManagement from '@/view/course/TaskManagement' // 我的课程子页面 作业管理


//学生班级管理
import MyClasses from '@/view/MyClasses' // 班级管理
import ClassesInfo from '@/view/ClassesInfo' // 班级详情
import StudentManagement from '@/view/StudentManagement' // 学生管理



//备课
import PrepareLessons from '@/view/PrepareLessons' // 备课首页
import PrepareLessonsSubject from '@/view/prepareLessons/Subject' // 备课 教学题目
import PrepareLessonsPapers from '@/view/prepareLessons/Papers' // 备课 教学试卷



import Login from '@/view/Login' // 登录
const NotFoundComponent = resolve => require(['@/view/404.vue'], resolve) //404
const Notice = resolve => require(['@/view/Notice.vue'], resolve) //通知公告

Vue.use(Router)

const TEACHER = role.teacher
const STUDENT = role.student
const ROOT = role.root

export default new Router({
  base: __dirname,
  mode: 'history',
  routes: [{
      path: '/',
      component: Main,
      children: [{
        path: '/',
        name: 'index',
        component: Index,
        meta: { requiresAuth: true, menuName: '/' }
      }, {
        path: '/course',
        name: 'course',
        component: Course,
        meta: { requiresAuth: true, role: TEACHER, menuName: '/course'  }
      }, {
        path: '/courseIndex',
        component: CourseIndex,
        children: [{
          path: '/courseIndex',
          component: CourseIndex2,
          meta: { requiresAuth: true, role: TEACHER, menuName: '/course'  }
        }, {
          path: '/course/statistics',
          component: CourseStatistics,
          meta: { requiresAuth: true, role: TEACHER, menuName: '/course' }
        }, {
          path: '/course/material',
          component: CourseMaterial,
          meta: { requiresAuth: true, role: TEACHER, menuName: '/course' }
        }, {
          path: '/course/task',
          component: TaskManagement,
          meta: { requiresAuth: true, role: TEACHER, menuName: '/course' }
        }]
      }, {
        path: '/myClasses',
        name: 'myClasses',
        component: MyClasses,
        meta: { requiresAuth: true, role: TEACHER, menuName: '/myClasses'  }
      }, {
        path: '/classesInfo',
        name: 'classesInfo',
        component: ClassesInfo,
        meta: { requiresAuth: true, role: TEACHER, menuName: '/myClasses'  }
      }, {
        path: '/studentManagement',
        name: 'studentManagement',
        component: StudentManagement,
        meta: { requiresAuth: true, role: TEACHER, menuName: '/myClasses'  }
      }, {
        path: '/notice',
        name: 'notice',
        component: Notice,
        meta: { requiresAuth: true, role: TEACHER, menuName: '/notice'  }
      }]
  }, {
    path: '/prepareLessons',
    component: Main2,
    children: [{
      path: '/prepareLessons',
      component: PrepareLessons,
      meta: { requiresAuth: true, role: TEACHER, menuName: '/prepareLessons' }
    }, {
      path: '/prepareLessons/subject',
      component: PrepareLessonsSubject,
      meta: { requiresAuth: true, role: TEACHER, menuName: '/prepareLessons/subject'  }
    }, {
      path: '/prepareLessons/paper',
      component: PrepareLessonsPapers,
      meta: { requiresAuth: true, role: TEACHER, menuName: '/prepareLessons/papers'  }
    }]
  }, {
    path: '/login',
    name: 'login',
    component: Login
  }, {
    path: '*',
    component: NotFoundComponent
  }]
})
